package entities 
{
	/**
	 * ...
	 * @author morgan
	 */
	public class SlimeEnemy extends Enemy
	{
		[Embed (source = "../../data/slime.png")] private var img_slime:Class;
		
		public const HITHEIGHT:int = 4; // If the player's feet are below (y + height - HITHEIGHT) then the player is hurt.
		public const SPEED:Number = 20;
		
		public function SlimeEnemy(x:int, y:int, scene:GameScene) 
		{
			super(x, y, scene);
			loadGraphic(img_slime, true, true, 16, 16);
			addAnimation("default", [0, 1, 2, 1], 5, true);
			play("default");
			
			velocity.x = SPEED;
		}
		
		override public function update():void 
		{
			super.update();
			if (justTouched(RIGHT))
			{
				velocity.x = -SPEED;
			}
			else if (justTouched(LEFT))
			{
				velocity.x = SPEED;
			}
		}
		
		override public function touchedPlayer(p:Player):void 
		{
			super.touchedPlayer(p);
			if (p.y + p.height < y + height - HITHEIGHT && p.velocity.y > 0)
			{
				kill();
				p.bounceOffEnemy();
			}
			else
			{
				
			}
		}
		
	}

}